{% load static %}
<!doctype html>
<html class="no-js" lang="zxx">
<head>
	<meta charset="utf-8">
	<title>基金列表</title>
	<link rel="shortcut icon" type="image/x-icon" href="{% static 'images/icon/favicon.png' %}">

	<!-- CSS here -->
	<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">

	<link rel="stylesheet" href="{% static 'css/style.css' %}">
</head>
<body>
	<header>
		<div class="header-area header-transparent">
			<div class="main-header header-sticky">
				<div class="container-fluid">
					<div class="menu-wrapper d-flex align-items-center justify-content-between">
						<div class="left-content d-flex align-items-center">
							<div class="logo">
								<a href="{% url 'index' %}"><img src="{% static 'images/logo/logo-test.png' %}" alt=""></a>
							</div>

							<!-- Main-menu -->
							<div class="main-menu d-none d-lg-block">
                                <nav>
                                    <ul id="navigation">
                                        <li><a href="{% url 'index' %}">主页</a></li>
                                        <li><a>列表<i class="fas fa-angle-down"></i></a>
                                            <ul class="submenu">
                                                <li><a href="{% url 'funds' %}">基金列表</a></li>
                                                <li><a href="{% url 'users' %}">用户列表</a></li>
                                            </ul>
                                        </li>
                                        <!--
                                        <li><a href="about.html">用户列表</a></li>
                                        <li><a href="#">Blog</a>
                                            <ul class="submenu">
                                                <li><a href="blog.html">用户列表</a></li>
                                                <li><a href="blog_details.html">Blog Details</a></li>
                                                <li><a href="elements.html">Element</a></li>
                                            </ul>
                                        </li>
                                        -->
                                        <li><a href="{% url 'chart' %}">统计图表</a></li>
                                    </ul>
                                </nav>
                            </div>
						</div>
						<!-- Button -->
						<div class="buttons">
							<ul>
								<li class="button-header">
									<form action="{% url 'logout' %}">
                                        <input type="submit" value="退出登录" class="btn header-btn2">
                                    </form>
								</li>
							</ul>
						</div>
					</div>
					<!-- Mobile Menu -->
					<div class="col-12">
						<div class="mobile_menu d-block d-lg-none"></div>
					</div>
				</div>
			</div>
		</div>
	</header>
	<main>
		<!-- Hero area Start-->
		<div class="slider-area">
			<div class="slider-height2 hero-bg2 hero-overly d-flex align-items-center">
				<div class="container">
					<div class="row">
						<div class="col-xl-12">
							<div class="hero-caption hero-caption2">
								<h2>基金列表</h2>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!--  Hero area End -->
		<div style="width: 95%;margin: 0 auto;margin-top: 15px">
			<table class="table table-bordered table-hover">
				<thead>
					<tr>
						<td>基金代码</td>
						<td>基金名称</td>
						<td>单位净值</td>
                        <td>基金经理</td>
                        <td>基金类型</td>
                        <td>基金操作</td>
					</tr>
				</thead>
				<tbody>
                {% for c in context %}
                    <tr>
                        <td>{{ c.0 }}</td>
                        <td>{{ c.1 }}</td>
                        <td>{{ c.2 }}</td>
                        <td>{{ c.3 }}</td>
                        {% if c.4 == 2 %}
                            <td>混合型</td>
                        {% elif c.4 == 1 %}
                            <td>股票型</td>
                        {% elif c.4 == 3 %}
                            <td>债券型</td>
                        {% elif c.4 == 4 %}
                            <td>指数型</td>
                        {% else %}
                            <td>货币型</td>
                        {% endif %}
                        <td>
                            <form style="display: inline" action="{% url 'detail' %}">
                                <input type="hidden" name="id" value="{{ c.0 }}">
                                <input class="btn btn-success" type="submit" style="height: 10px;padding: 15px 15px;margin-right: 15px" value="查看详情">
                            </form>
                            <!--
                            <form style="display: inline" action="{% url 'delete' %}">
                                <input type="hidden" name="id" value="{{ c.0 }}">
                                <input onclick="return deleteFund()" class="btn btn-danger" type="submit" style="height: 10px;padding: 15px 15px" value="删除">
                            </form>
                            -->
                        </td>
                    </tr>
                {% endfor %}
				</tbody>
			</table>
		</div>

        {% if  search == 0 %}
           <div style="text-align: center;margin-bottom: 10px">
            <form style="display: inline" action="{% url 'funds' %}">
              <input type="hidden" name="page" value="{{ page|add:-1 }}">
              <input class="btn" type="submit" onclick="return checkPage({{ page }}, 1)" style="height: 10px;padding: 15px 15px" value="上一页">
            </form>
            <p style="display: inline">当前是第{{ page }}页</p>
            <form style="display: inline" action="{% url 'funds' %}">
              <input type="hidden" name="page" value="{{ page|add:1 }}">
              <input class="btn" type="submit" onclick="return checkPage({{ page }}, 2)" style="height: 10px;padding: 15px 15px" value="下一页">
            </form>
        </div>

        {% endif %}


	</main>

    <script>
        function deleteFund() {
            if (confirm("确定要删除吗?"))
		     {
		         return true;
		     } else {
		         return false;
             }
        }
        function checkPage(page, option) {
            if (page == 1 && option == 1) {
                alert("已经是第一页！");
                return false;
            } else if (page == {{ max }} && option == 2) {
                alert("已经是最后一页！");
                return false;
            }
            return true;
        }
    </script>


</body>
</html>